﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsDonDatHangChiTiet
    {
        private double mDonGia = 0.0;
        private double mDonGiaNT = 0.0;
        private double mGiaMua = 0.0;
        private double mGiaMuaNT = 0.0;
        private double mHoaHong = 0.0;
        private double mHoaHongNT = 0.0;
        private string mKhoa = "";
        private string mKhoaDonDatHang = "";
        private string mKhoaDonViTinh = "";
        private string mKhoaHangHoa = "";
        private string mKhoaNhaCungCap = "";
        private double mQuyCach = 0.0;
        private double mSoLuong = 0.0;
        private double mSoLuongCungCap = 0.0;
        private double mThanhTien = 0.0;
        private double mThanhTienNT = 0.0;
        private int mThueSuat = 0;
        private double mTienMua = 0.0;
        private double mTienMuaNT = 0.0;
        private double mTienThue = 0.0;
        private double mTienThueNT = 0.0;
        private string mTinhTrang = "";
        private double mTriGiaCungCap = 0.0;
        private double mTriGiaCungCapNT = 0.0;
        private int mTyLeHoaHong = 0;

        public bool Load(string pKhoa)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                string commandText = "SELECT * FROM BH_DonDatHangChiTiet WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, commandParameters);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDonDatHang = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHangHoa = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDonViTinh = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mQuyCach = Conversions.ToDouble(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoLuong = Conversions.ToDouble(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetDecimal));
                    this.mDonGiaNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetDecimal));
                    this.mDonGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetDecimal));
                    this.mThanhTienNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetDecimal));
                    this.mThanhTien = Conversions.ToDouble(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoLuongCungCap = Conversions.ToDouble(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetDecimal));
                    this.mThueSuat = Conversions.ToInteger(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetInt32));
                    this.mTienThueNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetDecimal));
                    this.mTriGiaCungCapNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetDecimal));
                    this.mTriGiaCungCap = Conversions.ToDouble(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetDecimal));
                    this.mTinhTrang = Conversions.ToString(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetString));
                    this.mGiaMuaNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetDecimal));
                    this.mGiaMua = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienMuaNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienMua = Conversions.ToDouble(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetDecimal));
                    this.mKhoaNhaCungCap = Conversions.ToString(modGeneral.GetValue(dataReader, 0x15, modGeneral.typeOfColumn.GetString));
                    this.mTyLeHoaHong = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x16, modGeneral.typeOfColumn.GetInt32));
                    this.mHoaHongNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x17, modGeneral.typeOfColumn.GetDecimal));
                    this.mHoaHong = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x18, modGeneral.typeOfColumn.GetDecimal));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[0x19];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaDonDatHang", DbType.Int64, ParameterDirection.Input, this.mKhoaDonDatHang);
                commandParameters[2] = DBHelper.createParameter("@KhoaHangHoa", DbType.Int64, ParameterDirection.Input, this.mKhoaHangHoa);
                commandParameters[3] = DBHelper.createParameter("@KhoaDonViTinh", DbType.Int64, ParameterDirection.Input, this.mKhoaDonViTinh);
                commandParameters[4] = DBHelper.createParameter("@QuyCach", DbType.Date, ParameterDirection.Input, this.mQuyCach);
                commandParameters[5] = DBHelper.createParameter("@SoLuong", DbType.Date, ParameterDirection.Input, this.mSoLuong);
                commandParameters[6] = DBHelper.createParameter("@DonGiaNT", DbType.Date, ParameterDirection.Input, this.mDonGiaNT);
                commandParameters[7] = DBHelper.createParameter("@DonGia", DbType.Date, ParameterDirection.Input, this.mDonGia);
                commandParameters[8] = DBHelper.createParameter("@ThanhTienNT", DbType.Date, ParameterDirection.Input, this.mThanhTienNT);
                commandParameters[9] = DBHelper.createParameter("@ThanhTien", DbType.Date, ParameterDirection.Input, this.mThanhTien);
                commandParameters[10] = DBHelper.createParameter("@SoLuongCungCap", DbType.Date, ParameterDirection.Input, this.mSoLuongCungCap);
                commandParameters[11] = DBHelper.createParameter("@ThueSuat", DbType.Double, ParameterDirection.Input, this.mThueSuat);
                commandParameters[12] = DBHelper.createParameter("@TienThueNT", DbType.Date, ParameterDirection.Input, this.mTienThueNT);
                commandParameters[13] = DBHelper.createParameter("@TienThue", DbType.Date, ParameterDirection.Input, this.mTienThue);
                commandParameters[14] = DBHelper.createParameter("@TriGiaCungCapNT", DbType.Date, ParameterDirection.Input, this.mTriGiaCungCapNT);
                commandParameters[15] = DBHelper.createParameter("@TriGiaCungCap", DbType.Date, ParameterDirection.Input, this.mTriGiaCungCap);
                commandParameters[0x10] = DBHelper.createParameter("@TinhTrang", DbType.Int64, ParameterDirection.Input, this.mTinhTrang);
                commandParameters[0x11] = DBHelper.createParameter("@GiaMuaNT", DbType.Date, ParameterDirection.Input, this.mGiaMuaNT);
                commandParameters[0x12] = DBHelper.createParameter("@GiaMua", DbType.Date, ParameterDirection.Input, this.mGiaMua);
                commandParameters[0x13] = DBHelper.createParameter("@TienMuaNT", DbType.Date, ParameterDirection.Input, this.mTienMuaNT);
                commandParameters[20] = DBHelper.createParameter("@TienMua", DbType.Date, ParameterDirection.Input, this.mTienMua);
                commandParameters[0x15] = DBHelper.createParameter("@KhoaNhaCungCap", DbType.Int64, ParameterDirection.Input, this.mKhoaNhaCungCap);
                commandParameters[0x16] = DBHelper.createParameter("@TyLeHoaHong", DbType.Double, ParameterDirection.Input, this.mTyLeHoaHong);
                commandParameters[0x17] = DBHelper.createParameter("@HoaHongNT", DbType.Date, ParameterDirection.Input, this.mHoaHongNT);
                commandParameters[0x18] = DBHelper.createParameter("@HoaHong", DbType.Date, ParameterDirection.Input, this.mHoaHong);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_sp_DonDatHangChiTiet", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public double DonGia
        {
            get
            {
                return this.mDonGia;
            }
            set
            {
                this.mDonGia = value;
            }
        }

        public double DonGiaNT
        {
            get
            {
                return this.mDonGiaNT;
            }
            set
            {
                this.mDonGiaNT = value;
            }
        }

        public double GiaMua
        {
            get
            {
                return this.mGiaMua;
            }
            set
            {
                this.mGiaMua = value;
            }
        }

        public double GiaMuaNT
        {
            get
            {
                return this.mGiaMuaNT;
            }
            set
            {
                this.mGiaMuaNT = value;
            }
        }

        public double HoaHong
        {
            get
            {
                return this.mHoaHong;
            }
            set
            {
                this.mHoaHong = value;
            }
        }

        public double HoaHongNT
        {
            get
            {
                return this.mHoaHongNT;
            }
            set
            {
                this.mHoaHongNT = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaDonDatHang
        {
            get
            {
                return this.mKhoaDonDatHang;
            }
            set
            {
                this.mKhoaDonDatHang = value;
            }
        }

        public string KhoaDonViTinh
        {
            get
            {
                return this.mKhoaDonViTinh;
            }
            set
            {
                this.mKhoaDonViTinh = value;
            }
        }

        public string KhoaHangHoa
        {
            get
            {
                return this.mKhoaHangHoa;
            }
            set
            {
                this.mKhoaHangHoa = value;
            }
        }

        public string KhoaNhaCungCap
        {
            get
            {
                return this.mKhoaNhaCungCap;
            }
            set
            {
                this.mKhoaNhaCungCap = value;
            }
        }

        public double QuyCach
        {
            get
            {
                return this.mQuyCach;
            }
            set
            {
                this.mQuyCach = value;
            }
        }

        public double SoLuong
        {
            get
            {
                return this.mSoLuong;
            }
            set
            {
                this.mSoLuong = value;
            }
        }

        public double SoLuongCungCap
        {
            get
            {
                return this.mSoLuongCungCap;
            }
            set
            {
                this.mSoLuongCungCap = value;
            }
        }

        public double ThanhTien
        {
            get
            {
                return this.mThanhTien;
            }
            set
            {
                this.mThanhTien = value;
            }
        }

        public double ThanhTienNT
        {
            get
            {
                return this.mThanhTienNT;
            }
            set
            {
                this.mThanhTienNT = value;
            }
        }

        public int ThueSuat
        {
            get
            {
                return this.mThueSuat;
            }
            set
            {
                this.mThueSuat = value;
            }
        }

        public double TienMua
        {
            get
            {
                return this.mTienMua;
            }
            set
            {
                this.mTienMua = value;
            }
        }

        public double TienMuaNT
        {
            get
            {
                return this.mTienMuaNT;
            }
            set
            {
                this.mTienMuaNT = value;
            }
        }

        public double TienThue
        {
            get
            {
                return this.mTienThue;
            }
            set
            {
                this.mTienThue = value;
            }
        }

        public double TienThueNT
        {
            get
            {
                return this.mTienThueNT;
            }
            set
            {
                this.mTienThueNT = value;
            }
        }

        public string TinhTrang
        {
            get
            {
                return this.mTinhTrang;
            }
            set
            {
                this.mTinhTrang = value;
            }
        }

        public double TriGiaCungCap
        {
            get
            {
                return this.mTriGiaCungCap;
            }
            set
            {
                this.mTriGiaCungCap = value;
            }
        }

        public double TriGiaCungCapNT
        {
            get
            {
                return this.mTriGiaCungCapNT;
            }
            set
            {
                this.mTriGiaCungCapNT = value;
            }
        }

        public int TyLeHoaHong
        {
            get
            {
                return this.mTyLeHoaHong;
            }
            set
            {
                this.mTyLeHoaHong = value;
            }
        }
    }
}

